home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 June: Reference Library / Dev.CD Jun 95 / Dev.CD Jun 95.toast / What's New? / New System Software Extensions / QuickDraw 3D ß / Programming / Interfaces / QD3DCamera.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-04  |  9.3 KB  |  330 lines  |  [TEXT/MPS ]

  1. /******************************************************************************
  2.  **                                                                             **
  3.  **     Module:        QD3DCamera.h                                             **
  4.  **                                                                          **
  5.  **                                                                          **
  6.  **                                                                          **
  7.  **     Purpose:     Generic camera routines                                      **
  8.  **                                                                          **
  9.  **                                                                          **
  10.  **     Copyright (C) 1991-1994 Apple Computer, Inc. All rights reserved.     **    
  11.  **                                                                          **
  12.  *****************************************************************************/
  13. #ifndef QD3DCamera_h
  14. #define QD3DCamera_h
  15.  
  16. #if PRAGMA_ONCE
  17.     #pragma once
  18. #endif
  19.  
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif    /* __cplusplus */
  23.  
  24.  
  25. /******************************************************************************
  26.  **                                                                             **
  27.  **                            Data Structure Definitions                         **
  28.  **                                                                             **
  29.  *****************************************************************************/
  30. /*
  31.  *  The placement of the camera.
  32.  */
  33. typedef struct TQ3CameraPlacement{
  34.     TQ3Point3D        cameraLocation;        /*  Location point of the camera     */
  35.     TQ3Point3D        pointOfInterest;    /*  Point of interest                 */
  36.     TQ3Vector3D        upVector;            /*  "up" vector                     */
  37. } TQ3CameraPlacement;
  38.  
  39.  
  40. /*
  41.  *  The range of the camera.
  42.  */
  43. typedef struct TQ3CameraRange {
  44.     float    hither;        /*  Hither plane, measured from "from" towards "to"    */
  45.     float    yon;        /*  Yon  plane, measured from "from" towards "to"     */
  46. } TQ3CameraRange;
  47.  
  48.  
  49. /*
  50.  *  Viewport specification.  Origin is (-1, 1), and corresponds to the 
  51.  *  upper left-hand corner; width and height maximum is (2.0, 2.0),
  52.  *  corresponding to the lower left-hand corner of the window.  The
  53.  *  TQ3Viewport specifies a part of the viewPlane that gets displayed 
  54.  *    on the window that is to be drawn.
  55.  *  Normally, it is set with an origin of (-1.0, 1.0), and a width and
  56.  *  height of both 2.0, specifying that the entire window is to be
  57.  *  drawn.  If, for example, an exposure event of the window exposed
  58.  *  the right half of the window, you would set the origin to (0, 1),
  59.  *  and the width and height to (1.0) and (2.0), respectively.
  60.  *
  61.  */
  62. typedef struct TQ3CameraViewPort {
  63.     TQ3Point2D        origin;
  64.     float            width;
  65.     float            height;
  66. } TQ3CameraViewPort;
  67.  
  68.  
  69. typedef struct TQ3CameraData {
  70.     TQ3CameraPlacement    placement;
  71.     TQ3CameraRange        range;
  72.     TQ3CameraViewPort    viewPort;
  73. } TQ3CameraData;
  74.  
  75.  
  76. /*
  77.  *  An orthographic camera.
  78.  *
  79.  *  The lens characteristics are set with the dimensions of a
  80.  *  rectangular viewPort in the frame of the camera.
  81.  */
  82. typedef struct TQ3OrthographicCameraData {
  83.     TQ3CameraData        cameraData;
  84.     float    left;
  85.     float    top;
  86.     float    right;
  87.     float    bottom;
  88. } TQ3OrthographicCameraData;
  89.  
  90. /*
  91.  *  A perspective camera specified in terms of an arbitrary view plane.
  92.  *
  93.  *  This is most useful when setting the camera to look at a particular
  94.  *  object.  The viewPlane is set to distance from the camera to the object.
  95.  *  The halfWidth is set to half the width of the cross section of the object,
  96.  *  and the halfHeight equal to the halfWidth divided by the aspect ratio
  97.  *  of the viewPort.
  98.  * 
  99.  *  This is the only perspective camera with specifications for off-axis
  100.  *  viewing, which is desirable for scrolling.
  101.  */
  102. typedef struct TQ3ViewPlaneCameraData {
  103.     TQ3CameraData        cameraData;
  104.     float                viewPlane;
  105.     float                halfWidthAtViewPlane;
  106.     float                halfHeightAtViewPlane;
  107.     float                centerXOnViewPlane;
  108.     float                centerYOnViewPlane;
  109. } TQ3ViewPlaneCameraData;
  110.  
  111.  
  112. /*
  113.  *    A view angle aspect camera is a perspective camera specified in 
  114.  *    terms of the minimum view angle and the aspect ratio of X to Y.
  115.  *
  116.  */
  117. typedef struct TQ3ViewAngleAspectCameraData {
  118.     TQ3CameraData    cameraData;
  119.     float            fov;
  120.     float            aspectRatioXToY;
  121. } TQ3ViewAngleAspectCameraData;
  122.  
  123. /******************************************************************************
  124.  **                                                                             **
  125.  **                        public base class camera routines                     **
  126.  **                                                                             **
  127.  *****************************************************************************/
  128.  
  129.  
  130. EXPORT TQ3ObjectType Q3Camera_GetType(
  131.     TQ3CameraObject            camera);
  132.  
  133. EXPORT TQ3Status Q3Camera_SetData(
  134.     TQ3CameraObject            camera,
  135.     const TQ3CameraData        *cameraData);
  136.  
  137. EXPORT TQ3Status Q3Camera_GetData(
  138.     TQ3CameraObject            camera,
  139.     TQ3CameraData            *cameraData);
  140.     
  141. EXPORT TQ3Status Q3Camera_SetPlacement(
  142.     TQ3CameraObject            camera,
  143.     const TQ3CameraPlacement    *placement);
  144.     
  145. EXPORT TQ3Status Q3Camera_GetPlacement(
  146.     TQ3CameraObject            camera,
  147.     TQ3CameraPlacement        *placement);
  148.     
  149. EXPORT TQ3Status Q3Camera_SetRange(
  150.     TQ3CameraObject            camera,
  151.     const TQ3CameraRange        *range);
  152.  
  153. EXPORT TQ3Status Q3Camera_GetRange(
  154.     TQ3CameraObject            camera,
  155.     TQ3CameraRange            *range);
  156.  
  157. EXPORT TQ3Status Q3Camera_SetViewPort(
  158.     TQ3CameraObject            camera,
  159.     const TQ3CameraViewPort    *viewPort);
  160.  
  161. EXPORT TQ3Status Q3Camera_GetViewPort(
  162.     TQ3CameraObject            camera,
  163.     TQ3CameraViewPort        *viewPort);
  164.  
  165. EXPORT TQ3Status Q3Camera_GetWorldToView( 
  166.     TQ3CameraObject            camera,
  167.     TQ3Matrix4x4                *worldToView);
  168.  
  169. EXPORT TQ3Status Q3Camera_GetWorldToFrustum( 
  170.     TQ3CameraObject            camera,
  171.     TQ3Matrix4x4                *worldToFrustum);
  172.  
  173. EXPORT TQ3Status Q3Camera_GetViewToFrustum(
  174.     TQ3CameraObject            camera,
  175.     TQ3Matrix4x4                *viewToFrustum);
  176.  
  177.  
  178. /******************************************************************************
  179.  **                                                                             **
  180.  **                            Specific Camera Routines                          **
  181.  **                                                                             **
  182.  *****************************************************************************/
  183.  
  184. /******************************************************************************
  185.  **                                                                             **
  186.  **                            Orthographic Camera                                  **
  187.  **                                                                             **
  188.  *****************************************************************************/
  189.  
  190. EXPORT TQ3CameraObject Q3OrthographicCamera_New(
  191.     const TQ3OrthographicCameraData    *orthographicData);
  192.  
  193. EXPORT TQ3Status Q3OrthographicCamera_GetData(
  194.     TQ3CameraObject                    camera,
  195.     TQ3OrthographicCameraData        *cameraData);
  196.  
  197. EXPORT TQ3Status Q3OrthographicCamera_SetData(
  198.     TQ3CameraObject                    camera,
  199.     const TQ3OrthographicCameraData    *cameraData);
  200.  
  201. EXPORT TQ3Status Q3OrthographicCamera_SetLeft(
  202.     TQ3CameraObject            camera,
  203.     float                    left);
  204.     
  205. EXPORT TQ3Status Q3OrthographicCamera_GetLeft(
  206.     TQ3CameraObject            camera,
  207.     float                    *left);
  208.  
  209. EXPORT TQ3Status Q3OrthographicCamera_SetTop(
  210.     TQ3CameraObject            camera,
  211.     float                    top);
  212.     
  213. EXPORT TQ3Status Q3OrthographicCamera_GetTop(
  214.     TQ3CameraObject            camera,
  215.     float                    *top);
  216.  
  217. EXPORT TQ3Status Q3OrthographicCamera_SetRight(
  218.     TQ3CameraObject            camera,
  219.     float                    right);
  220.     
  221. EXPORT TQ3Status Q3OrthographicCamera_GetRight(
  222.     TQ3CameraObject            camera,
  223.     float                    *right);
  224.  
  225. EXPORT TQ3Status Q3OrthographicCamera_SetBottom(
  226.     TQ3CameraObject            camera,
  227.     float                    bottom);
  228.     
  229. EXPORT TQ3Status Q3OrthographicCamera_GetBottom(
  230.     TQ3CameraObject            camera,
  231.     float                    *bottom);
  232.  
  233.  
  234. /******************************************************************************
  235.  **                                                                             **
  236.  **                            ViewPlane Camera                                  **
  237.  **                                                                             **
  238.  *****************************************************************************/
  239.  
  240. EXPORT TQ3CameraObject Q3ViewPlaneCamera_New(
  241.     const TQ3ViewPlaneCameraData    *cameraData);
  242.     
  243. EXPORT TQ3Status Q3ViewPlaneCamera_GetData(
  244.     TQ3CameraObject                camera,
  245.     TQ3ViewPlaneCameraData        *cameraData);
  246.  
  247. EXPORT TQ3Status Q3ViewPlaneCamera_SetData(
  248.     TQ3CameraObject                camera,
  249.     const TQ3ViewPlaneCameraData    *cameraData);
  250.  
  251. EXPORT TQ3Status Q3ViewPlaneCamera_SetViewPlane(
  252.     TQ3CameraObject        camera,
  253.     float                viewPlane);
  254.     
  255. EXPORT TQ3Status Q3ViewPlaneCamera_GetViewPlane(
  256.     TQ3CameraObject        camera,
  257.     float                *viewPlane);
  258.  
  259. EXPORT TQ3Status Q3ViewPlaneCamera_SetHalfWidth(
  260.     TQ3CameraObject        camera,
  261.     float                halfWidthAtViewPlane);
  262.  
  263. EXPORT TQ3Status Q3ViewPlaneCamera_GetHalfWidth(
  264.     TQ3CameraObject        camera,
  265.     float                *halfWidthAtViewPlane);
  266.  
  267. EXPORT TQ3Status Q3ViewPlaneCamera_SetHalfHeight(
  268.     TQ3CameraObject        camera,
  269.     float                halfHeightAtViewPlane);
  270.  
  271. EXPORT TQ3Status Q3ViewPlaneCamera_GetHalfHeight(
  272.     TQ3CameraObject        camera,
  273.     float                *halfHeightAtViewPlane);
  274.     
  275. EXPORT TQ3Status Q3ViewPlaneCamera_SetCenterX(
  276.     TQ3CameraObject        camera,
  277.     float                centerXOnViewPlane);
  278.     
  279. EXPORT TQ3Status Q3ViewPlaneCamera_GetCenterX(
  280.     TQ3CameraObject        camera,
  281.     float                *centerXOnViewPlane);
  282.     
  283. EXPORT TQ3Status Q3ViewPlaneCamera_SetCenterY(
  284.     TQ3CameraObject        camera,
  285.     float                centerYOnViewPlane);
  286.     
  287. EXPORT TQ3Status Q3ViewPlaneCamera_GetCenterY(
  288.     TQ3CameraObject        camera,
  289.     float                *centerYOnViewPlane);
  290.  
  291.  
  292. /******************************************************************************
  293.  **                                                                             **
  294.  **                            View Angle Aspect Camera                          **
  295.  **                                                                             **
  296.  *****************************************************************************/
  297.  
  298. EXPORT TQ3CameraObject Q3ViewAngleAspectCamera_New(
  299.     const TQ3ViewAngleAspectCameraData    *cameraData);
  300.  
  301. EXPORT TQ3Status Q3ViewAngleAspectCamera_SetData(
  302.     TQ3CameraObject                        camera,
  303.     const TQ3ViewAngleAspectCameraData    *cameraData);
  304.     
  305. EXPORT TQ3Status Q3ViewAngleAspectCamera_GetData(
  306.     TQ3CameraObject                camera,
  307.     TQ3ViewAngleAspectCameraData    *cameraData);
  308.  
  309. EXPORT TQ3Status Q3ViewAngleAspectCamera_SetFOV(
  310.     TQ3CameraObject    camera,
  311.     float            fov);
  312.  
  313. EXPORT TQ3Status Q3ViewAngleAspectCamera_GetFOV(
  314.     TQ3CameraObject    camera,
  315.     float            *fov);
  316.  
  317. EXPORT TQ3Status Q3ViewAngleAspectCamera_SetAspectRatio(
  318.     TQ3CameraObject    camera,
  319.     float            aspectRatioXToY);
  320.     
  321. EXPORT TQ3Status Q3ViewAngleAspectCamera_GetAspectRatio(
  322.     TQ3CameraObject    camera,
  323.     float            *aspectRatioXToY);
  324.  
  325. #ifdef __cplusplus
  326. }
  327. #endif    /* __cplusplus */
  328.  
  329. #endif  /*  QD3DCamera_h  */
  330.